package com.sgcc.ln.pmos.e_ln_home.fragment;

import com.blankj.utilcode.util.ToastUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.sgcc.ln.pmos.common.base.MvpBaseRecycleFragment;
import com.sgcc.ln.pmos.e_ln_home.adapter.UserTypeAdapter;
import com.sgcc.ln.pmos.e_ln_home.bean.UserTypeListBean;
import com.sgcc.ln.pmos.e_ln_home.contract.UserTypeListContract;
import com.sgcc.ln.pmos.e_ln_home.presenter.UserListPresenter;

import java.util.Calendar;

/**
 * 用户类型切换历史记录
 */
public class UsertTypeListFregment extends MvpBaseRecycleFragment<UserTypeListBean.DataDTO, UserListPresenter> implements UserTypeListContract.View {

    private UserTypeAdapter userTypeAdapter;
    int year = 2022;
    @Override
    protected UserListPresenter createPresenter() {
        return new UserListPresenter();
    }

    @Override
    public BaseQuickAdapter getAdapter() {
        userTypeAdapter = new UserTypeAdapter(mContext);
        userTypeAdapter.setOnItemClickListener(new UserTypeAdapter.OnItemClickListener() {
            @Override
            public void itemClickListener(int position, UserTypeListBean.DataDTO bean) {

            }
        });
        return userTypeAdapter;
    }

    @Override
    public void getDataRequest(int listSize, boolean isloading) {
        super.getDataRequest(listSize, isloading);

        mPresenter.getUserTypeList(year + "");
    }

//    @Override
//    public String getTitleText() {
//        return "身份转换记录";
//    }

    @Override
    protected void initViews() {
        super.initViews();
        year = Calendar.getInstance().get(Calendar.YEAR);
    }

    @Override
    public void querySuccess(UserTypeListBean respon) {
        if (respon != null) {
            loadSuccess(false, respon.getData());
        } else {
            ToastUtils.showShort("返回数据有误");
        }
    }

    public void setTime(String time) {
        year=Integer.valueOf(time);
        refresh(false);
    }

    @Override
    public void queryFaile() {

    }

}
